<?php 
namespace App\Infra\User;

use App\Models\GiRecord;
use App\Utils\ModelSDK\ModelOperator;
use DB;

class GiRecordManage{

	use ModelOperator;

	public function createRecord($data){
		$this->create(GiRecord::class,$data);
	}

	public function getRecordList($conditions){
		return $this->findModel(GiRecord::class,GiRecord::query(),$conditions,true)->orderBy('created_at','DESC')->get();
	}

	public function updateRecord($id,$data){
		$this->update(GiRecord::class,$id,$data);
	}

	public function getRecordToDay($conditions){
		return DB::select(GiRecord::$SQL_SELECT_TODAY,[$conditions['wechat_user_id']]);
	}

	public function getRecordToDayAndId($conditions){
		return DB::select(GiRecord::$SQL_SELECT_ID_AND_TODAY,[$conditions['id'],$conditions['wechat_user_id']]);
	}

	public function getRecordById($id){
		return GiRecord::find($id);
	}
}